package com.lmt_5;

import java.util.StringJoiner;

public class Test2 {
    public static void main(String[] args) throws CloneNotSupportedException {
        int arr[] = new int[]{1,2,3,4,5};
        String arrayData = getArrayData(arr);
        System.out.println(arrayData);
        System.out.println("=============");
        StringJoiner stringJoiner = new StringJoiner(",","[","]");//间隔副,起始符，终止副
        stringJoiner.add("java1");
        stringJoiner.add("java2");
        System.out.println(stringJoiner);


    }
    public  static String getArrayData(int []arr){
        // 判断是否为空

        if (arr.length == 0){
            return "";
        }

        StringBuilder stringBuilder = new StringBuilder("[");
        for (int m:arr){
            stringBuilder.append(m);
            stringBuilder.append(",");
        }
        stringBuilder.append("]");
        return stringBuilder.toString();
    }
}
